package com.kly.user.service.traffic;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.fqgj.common.api.Response;
import com.fqgj.common.utils.StringUtils;
import com.kly.user.config.NacosValueConfig;
import com.kly.user.db.dao.UserAppsflyerFromAppDao;
import com.kly.user.db.dao.UserAppsflyerReportDetailDao;
import com.kly.user.db.dao.UserDao;
import com.kly.user.db.entity.UserAppsflyerFromAppEntity;
import com.kly.user.db.entity.UserAppsflyerReportDetailEntity;
import com.kly.user.db.entity.UserEntity;
import com.kly.user.dto.TrafficSourceDto;
import com.kly.user.dto.vo.TrafficSourceReq;
import com.kly.user.enums.AppCodeEnum;
import com.kly.user.enums.TrafficSourceEnum;
import com.kly.user.service.WhiteListService;
import com.kly.user.serviceImpl.UserTrafficSourceServiceImpl;
import com.kly.user.serviceImpl.dto.TrafficSourceEnableSwitch;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Service("mebooTrafficFacadeService")
public class MebooTrafficFacadeServiceImpl implements TrafficFacadeService {

    @Resource
    WhiteListService whiteListService;


    @PostConstruct
    public void setUp() {
        UserTrafficSourceServiceImpl.trafficFacadeService.put(AppCodeEnum.MEBOO.getAppCode(), this);
        UserTrafficSourceServiceImpl.trafficFacadeService.put(AppCodeEnum.MEBOO_IOS.getAppCode(), this);
    }

    @Override
    public Response<TrafficSourceDto> getTrafficSource(TrafficSourceReq req, String appCode) {
        // 获取白名单配置
        final Boolean whiteUserFlag = whiteListService.in(req.getAppCode(), req.getUserCode(), req.getMobile(), req.getEmail()).getData();

        // Meboo 用户目前当作非自然流量
        return Response.ok(TrafficSourceDto.toDto(null, TrafficSourceEnum.All, whiteUserFlag));

    }
}
